1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to forcibly terminating a thread blocked on an input/output operation. More particularly, apparatuses and methods consistent with the present invention relate to forcibly terminating a thread blocked on an input/output operation by terminating the input/output operation, transmitting a user-defined signal to the thread blocked on the input/output operation, and temporarily releasing the corresponding thread from a blocked state such that a ThreadDeath Exception is generated in the thread attempting to execute an input/output system call.
2. Description of the Related Art
Java is an object-oriented programming language that runs a written code in a platform independent manner. As used herein, the term “platform” refers to, for example, hardware on which a program executes, or a software environment such as an operating system. The code written using Java is complied as a Java byte code by a Java compiler. The Java byte code is executed by a Java virtual machine that supports a variety of hardware-based platforms.
FIG. 1 is a block diagram showing an apparatus for executing a Java application according to the related art. A Java application apparatus 10 includes an application manager 11, applications 12a, 12b and 12c, middleware 13, a Java virtual machine 14, and an operating system 15.
As shown in FIG. 1, the applications include Java application 1, referenced as 12a, Java application 2, referenced as 12b, and a native application 12c. 
The application manager 11 manages a life cycle of an application by changing a state of the application. The middleware 13, such as an open cable application platform (OCAP), an advanced open cable application platform (ACAP), or the like, manages the operation of the application.
The Java virtual machine 14 loads a class included in the application to a memory, converts an execution code of the class into a command code of the operating system 15, and manages resources that are allocated to the application.
As described above, the application manager II manages the life cycle of the application. To do so, first, the application manager 11 checks a list of threads running in the application that is desired to be terminated. When there is no thread in the list, the application manager 11 immediately terminates the application. When there are threads in the list, the application manager 111 terminates the threads that are included in the list.
In order to terminate the threads included in the list, the application manager 11 checks a thread class object of a first thread in the list and calls an interrupt function (e.g., Thread.interrupt ( )) with respect to a corresponding object. The interrupt function temporarily releases the thread from a blocked state. At this time, the application manager 11 calls a stop function (e.g., Thread.stop ( )) with respect to a corresponding object. The stop function generates a ThreadDeath Exception, such that the thread terminates. The application manager 11 repeats this process until all of the threads included in the list are terminated.
However, when there is a thread that is blocked on an input/output operation (hereinafter, simply referred to as an “I/O operation”) in the application, it may be impossible for the application manager 11 to effectively terminate the corresponding thread by the interrupt function and the stop function.
In general, when a function with respect to an I/O operation is called in a Java program, the function attempts to execute an I/O system call of the operating system 15. The system call is executed in a kernel mode, in which the thread is in a blocked state, waiting for the I/O operation. However, since the interrupt function and the stop function are executed in a user mode by the application manager 11, it may be impossible for the interrupt function and the stop function to affect the thread running in the kernel mode. That is, it is not until the I/O system call is returned and the kernel mode is changed into the user mode that the thread terminates.
A method for initiating a cleanup process by monitoring a plurality of related threads in a Java virtual machine environment and of making a determination as to whether a thread within the plurality of related threads is active on the basis of the status information is disclosed in U.S. Pat. No. 6,842,898 (Method and Apparatus for Monitoring and Handling Events for a Collection of Related Threads in a Data Processing System). However, the invention disclosed in U.S. Pat. No. 6,842,898 proposes only a method for terminating a general thread, but not a method for terminating a thread that is blocked on an I/O operation.
Therefore, there is a demand for a method for effectively terminating a thread that is blocked on an I/O operation.